import axios from "axios";

export const fetchData = (fn) => {
  axios
    .get(
      "https://www.fastmock.site/mock/6272b92cad2ed3e6885655ba6037f8a5/jest/axios-demo"
    )
    .then((response) => {
      fn(response.data);
    });
};

// 直接返回 promise
export const fetchDataPromice = () => {
  return axios.get(
    "https://www.fastmock.site/mock/6272b92cad2ed3e6885655ba6037f8a5/jest/axios-demo"
  );
};

// 异常
export const fetchDataPromiceError = () => {
  return axios.get("http://alomy.cn/error");
};
